﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Entity
{
    /// <summary>
    /// 分页查询参数
    /// </summary>
    public class PaginationQuery
    {
        /// <summary>
        /// 当前页码（默认1）
        /// </summary>
        public int PageIndex { get; set; } = 1;

        /// <summary>
        /// 每页条数（默认10）
        /// </summary>
        public int PageSize { get; set; } = 10;

        /// <summary>
        /// 计算跳过的条数（用于SQL分页）
        /// </summary>
        public int SkipCount => (PageIndex - 1) * PageSize;
    }

    /// <summary>
    /// 分页查询结果
    /// </summary>
    /// <typeparam name="T">数据类型</typeparam>
    public class PaginationResult<T>
    {
        /// <summary>
        /// 当前页数据
        /// </summary>
        public List<T> Data { get; set; } = new List<T>();

        /// <summary>
        /// 总条数
        /// </summary>
        public int TotalCount { get; set; }

        // 计算总页数，只读
        public int TotalPages => TotalCount > 0 ? (int)Math.Ceiling((double)TotalCount / PageSize) : 0;

        /// <summary>
        /// 当前页码
        /// </summary>
        public int PageIndex { get; set; }

        /// <summary>
        /// 每页条数
        /// </summary>
        public int PageSize { get; set; }
        public int Total { get; set; } // 必须包含此属性
    }
}
